<template>
  <div class="home">
    <el-container>
      <el-header>
        <TopBar></TopBar>
      </el-header>
      <el-container>
        <MenuList></MenuList>
        <el-main>
          <!-- <button @click="addShow(true)">添加</button>
          <TableList
            :loading="loading"
            :tableData="tableData"
            :tableHead="tableHead"
            @stateChange="stateChange"
            @updateNotice="updateNotice"
            @deleteNotice="deleteNotice"
            @textView="textView"
          /> -->
        
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import TopBar from "@/components/TopBar";
import MenuList from "@/components/MenuList";
import TableList from "@/components/common/Table";
import NoticeDialog from "@/components/common/NoticeDialog";

import http from "../api/administratorrole";
export default {
  name: "Index",
  components: {
    TopBar,
    MenuList,
    TableList,
    NoticeDialog,
  },
  data() {
    return {

      loading: false,
      tableData: [],
      tableHead: [
        {
          label: "ID",
          prop: "id",
        },
        {
          label: "维修类型 ",
          prop: "typename",
          type: "isclick",
        },
        {
          label: "状态",
          prop: "state",
          type: "switch",
        },
        {
          label: "操作",
          type: "button",
          button: {
            update: true,
            delete: true,
          },
        },
        {
          label: "添加人",
          prop: "edituser",
          type: "isclick",
        },
        {
          label: "头像",
          prop: "picture",
          type: "img",
          imgclick: true,
          formatter: (row, prop) => {
            // console.log(row, prop, this.$config.baseUrl);
            // console.log(row, prop, this.$config.baseUrl);
            //模拟测试
            let defImg =
              "/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2F30%2F90%2F40%2F309040a0602c672cebc6ab3a1bbbc8cd.jpg";
            let baseUrl = "https://gimg2.baidu.com/image_search";
            return !prop ? defImg : this.$config.baseUrl + "/upload/" + prop;
            return baseUrl + "upload" + prop;
          },
        },
        // {
        //   label: "图片",
        //   prop: "images",
        //   type: "img",
        //   imgclick: true,
        //   formatter: (row, prop) => {
        //     // console.log(row, prop, this.$config.baseUrl);
        //     let defImg =
        //       "/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2F84%2F69%2Fa9%2F8469a992634242df4291b3265f9f2a38.jpg";
        //     prop = [
        //       {
        //         url: defImg,
        //       },
        //       {
        //         url: defImg,
        //       },
        //     ];
        //     let baseUrl = "https://gimg2.baidu.com/image_search"
        //     const images = prop.map(item=>baseUrl+item.url)
        //     return {
        //       url:  images[0],
        //       images
        //     }

        //   },
        // },
      ],
    };
  },
  mounted() {
  },
  methods: {
   
    stateChange(data) {
      console.log("stateChange", data);
    },
    updateNotice(data) {
      console.log("updateNotice", data);
    },
    deleteNotice(data) {
      console.log("deleteNotice", data);
    },
    textView(data) {
      console.log("textView", data);
    },
    // async getNoticeList() {
    //   const { data } = await http.getNewsList();
    //   this.tableData = data.list;
    // },
  },
};
</script>
<style scoped>
</style>
